package com.crm.dao.after_sale;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.crm.pojo.AftetSaleServer;
import com.crm.pojo.ClientComplaint;

public interface ComplaintDao extends CrudRepository<ClientComplaint, Long> {

	/**
	 * 根据投诉编号分页查询客户投诉
	 * @param complaintId
	 * @param pageable
	 * @return
	 */
	@Query("from ClientComplaint c where c.complaintId = ?1 and c.clientComplaintIsDel = '否' order by c.peopleId")
	public List<ClientComplaint> findComplaintBycomplaintId(Long complaintId, Pageable pageable);
	
	/**
	 * 分页查询客户投诉
	 * @param pageable
	 * @return
	 */
	@Query("from ClientComplaint c where c.clientComplaintIsDel = '否' order by c.peopleId")
	public List<ClientComplaint> findComplaintByPage(Pageable pageable);
	
	/**
	 * 分页查询客户投诉的数量
	 * @return
	 */
	@Query("select count(*) from ClientComplaint c where c.clientComplaintIsDel = '否' ")
	public Long countComplaintByPage();
	
	/**
	 * 通过投诉主题模糊分页查询客户投诉
	 * @param theme
	 * @param pageable
	 * @return
	 */
	@Query("from ClientComplaint c where c.theme like ?1 and c.clientComplaintIsDel = '否' order by c.peopleId")
	public List<ClientComplaint> findByTheme(String theme, Pageable pageable);
	
	/**
	 * 通过投诉主题模糊分页查询客户投诉的数量
	 * @param theme
	 * @return
	 */
	@Query("select count(*) from ClientComplaint c where c.theme like ?1 and c.clientComplaintIsDel = '否'")
	public Long countByTheme(String theme);
}
